module.exports={
    verify : function verify(req,res,done){
        const jwt = this.jwt
        if(req.raw.headers['authorization'].indexOf('Bearer ')!=-1)
        jwt.verify(req.raw.headers['authorization'].slice(7), onVerify)

        function onVerify (err, decoded) {
            console.log(decoded)
            console.log(err)
          if (err || !decoded.user || !decoded.password) {
            return done(new Error('Token not valid'))
          }

          level.get(decoded.user, onUser)
          function onUser (err, password) {
            if (err) {
              if (err.notFound) {
                return done(new Error('Token not valid'))
              }
              return done(err)
            }
    
            if (!password || password !== decoded.password) {
              return done(new Error('Token not valid'))
            }
    
            done()
          }
        }
        res.code(401).send({code:'401'})
        return done(new Error('无Token'))
    }
}